
import time
class Test:
    def prt(self):
        self.factoryresulstr = "FACTORY_RESULT=SN:pass,SDNAND:<>,AFE4410<>,ICM40607:<>,ELECTRIC_MACHINERY:pass,CHARGE:<>,POWER_WASTE:<>,BLUETOOTH:<>"
        # 空列表
        #self.factoryresulstr = "123"
        try:
            self.factoryresulstr = (self.factoryresulstr.split("="))[1]
        except:
            print("数据没有等号")
            pass

        self.factoryresullist = self.factoryresulstr.split(",")

        self.factoryresul_Dict = {}
        for iterm in self.factoryresullist:
            try:
                self.factoryresul_Dict[iterm.split(":")[0]] = iterm.split(":")[1]
            except:
                print("数据来源错误")
                pass
        # 清空列表
        self.factoryresulexcel_list = []

        # 添加时间
        self.factoryresulexcel_list.append(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
        if 'SN' in self.factoryresul_Dict.keys():  #
            self.factoryresulexcel_list.append(self.factoryresul_Dict["SN"])
        else:
            self.factoryresulexcel_list.append(" ")
        if 'SDNAND' in self.factoryresul_Dict.keys():
            self.factoryresulexcel_list.append(self.factoryresul_Dict["SDNAND"])
        else:
            self.factoryresulexcel_list.append(" ")

        if 'AFE4410' in self.factoryresul_Dict.keys():
            self.factoryresulexcel_list.append(self.factoryresul_Dict["AFE4410"])
        else:
            self.factoryresulexcel_list.append(" ")
        if 'ICM40607' in self.factoryresul_Dict.keys():
            self.factoryresulexcel_list.append(self.factoryresul_Dict["ICM40607"])
        else:
            self.factoryresulexcel_list.append(" ")
        if 'ELECTRIC_MACHINERY' in self.factoryresul_Dict.keys():
            self.factoryresulexcel_list.append(self.factoryresul_Dict["ELECTRIC_MACHINERY"])
        else:
            self.factoryresulexcel_list.append(" ")

        if 'CHARGE' in self.factoryresul_Dict.keys():
            self.factoryresulexcel_list.append(self.factoryresul_Dict["CHARGE"])
        else:
            self.factoryresulexcel_list.append(" ")

        if 'POWER_WASTE' in self.factoryresul_Dict.keys():
            self.factoryresulexcel_list.append(self.factoryresul_Dict["POWER_WASTE"])
        else:
            self.factoryresulexcel_list.append(" ")

        if 'BLUETOOTH' in self.factoryresul_Dict.keys():
            self.factoryresulexcel_list.append(self.factoryresul_Dict["BLUETOOTH"])
        else:
            self.factoryresulexcel_list.append(" ")
        print(self.factoryresulexcel_list)

t = Test()
t.prt()

